package DancingBug;


/* 
 * AP(r) Computer Science GridWorld Case Study:
 * Copyright(c) 2005-2006 Cay S. Horstmann (http://horstmann.com)
 *
 * This code is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * @author Cay Horstmann
 * @author Chris Nevison
 * @author Barbara Cloud Wells
 */

import java.util.ArrayList;

import info.gridworld.actor.Bug;


public class DancingBug extends Bug
{
    private int steps;
    private int times;
    private ArrayList<Integer> dance;


    public DancingBug(ArrayList<Integer> arr)
    {
        steps = 0;
        times=0;
        dance = arr;
    }


    public void act()
    {
        if (steps < 2 && canMove())
        {
            move();
            steps++;
        }
        else
        {
            for(int i=0; i<dance.get(times); i++)
            	turn();
            steps = 0;
            times++;
	        if(times > dance.size()-1)
	        	times = 0;
        }
        
    }
}
